#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e5+7;
ll T,n,ans,vis[N];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%lld",&T);
    while(T--)
    {
        ans=0;
        memset(vis,0,sizeof(vis));
        scanf("%lld",&n);
        for(ll i=1;i<=n;i++)
        {
            ll x;
            scanf("%lld",&x);
            vis[x]++;
            if(vis[x]==2)
            {
                ans+=x;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}
